package top.houry.im.ui.init;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.stage.StageStyle;
import top.houry.im.ui.abstracts.ImUiStageAbstract;
import top.houry.im.ui.interfaces.ImUiLoginEvent;

import java.io.IOException;


public abstract class ImUiLoginInit extends ImUiStageAbstract {

    private static final String RESOURCE_NAME = "/fxml/login/login.fxml";

    public ImUiLoginEvent loginEvent;

    public Label networkTip;
    public Button loginMin;          // 登陆窗口最小化
    public Button loginClose;        // 登陆窗口退出
    public Button loginButton;       // 登陆按钮
    public TextField userId;          // 用户账户窗口
    public PasswordField userPassword;// 用户密码窗口

    public ImUiLoginInit(ImUiLoginEvent loginEvent) {
        this.loginEvent = loginEvent;
        try {
            root = FXMLLoader.load(getClass().getResource(RESOURCE_NAME));
        } catch (IOException e) {
            e.printStackTrace();
        }
        Scene scene = new Scene(root);
        scene.setFill(Color.TRANSPARENT);
        setScene(scene);
        initStyle(StageStyle.TRANSPARENT);
        setResizable(false);
        this.getIcons().add(new Image("/fxml/main/img/head/logo.png"));
        obtain();
    }


    private void obtain() {
        networkTip = lookup("network_tip", Label.class);
        loginMin = lookup("login_min", Button.class);
        loginClose = lookup("login_close", Button.class);
        loginButton = lookup("login_button", Button.class);
        userId = lookup("userId", TextField.class);
        userPassword = lookup("userPassword", PasswordField.class);
    }

}
